
cc.Class({
    extends: require('Monster'),

    properties: {
        label :cc.Label
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.tryAttackList = [];
    },

    gameUpdate (dt) {
        this._super(dt)
        let i=0;
        let d = Date.now();
        this.tryAttackList.push({
            time : d,
            blood : this.blood
        })
        
        while(i<this.tryAttackList.length){
            var obj = this.tryAttackList[i];
            if(d-obj.time > 1000){
                this.tryAttackList.splice(i,1);
            } else {
                i++
            }
        }
        if(this.tryAttackList.length > 2){
            let first = this.tryAttackList[0]
            let end = this.tryAttackList[this.tryAttackList.length-1]
            this.label.string = first.blood - end.blood;
        }
        
    },
});
